package com.naiterui.ehp.bs.b2c.order.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.naiterui.ehp.bs.b2c.order.entity.OrderLog;
import com.naiterui.ehp.bs.b2c.order.repository.IOrderLogRepository;
import com.naiterui.ehp.bs.b2c.order.service.IOrderLogService;

@Service
public class OrderLogServiceImpl implements IOrderLogService {
    @Autowired
    private IOrderLogRepository orderLogRepository;

    @Override
    public void save(Long orderId, String content, Integer beforeOrderStatus, Integer afterOrderStatus, String operator) {
        this.orderLogRepository.save(OrderLog.builder()
                                             .orderId(orderId)
                                             .content(content)
                                             .beforeOrderStatus(beforeOrderStatus)
                                             .afterOrderStatus(afterOrderStatus)
                                             .createdAt(new Date())
                                             .createdBy(operator)
                                             .changedAt(new Date())
                                             .changedBy(operator)
                                             .build());
    }
}
